package familytree.yu.com.sso.exception;

import familytree.yu.com.sso.enums.CodeBaseEnum;

/**
 * @Author: yuyunbo
 * @Date: 2021/2/22 22:35
 * @Description:
 */
public class SsoException extends RuntimeException {
    private int code;

    public static SsoException fromCode(CodeBaseEnum ee) {
        return new SsoException(ee);
    }

    public static void thrException(CodeBaseEnum ee) {
        throw new SsoException(ee);
    }

    public static void touch(boolean touch, CodeBaseEnum ee) {
        if (touch) {
            thrException(ee);
        }

    }

    public SsoException(int code, String msg) {
        super(msg);
        this.code = code;
    }

    public SsoException(CodeBaseEnum ee) {
        super(ee.msg());
        this.code = ee.code();
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
